package com.ch04.web.controller;

import com.ch04.pojo.BackendUser;
import com.ch04.service.BackendUserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Jane
 * @date 2024-05-27 15:39
 */

@Controller
public class LoginController {

    @Resource
    BackendUserService backendUserService;

    @RequestMapping("/backend/login")  //管理员
    public String toBackendLogin(){
        return "backendlogin";
    }

    @RequestMapping("/devuser/login")  //开发者
    public String toDevLogin(){
        return "devlogin";
    }



    @RequestMapping("/backend/test")
    @ResponseBody
    public String test(){
        return "test";
    }

//    @RequestMapping("/getUser")
    @RequestMapping("/getUser/{id}")//springboot支持restFul风格的请求
    @ResponseBody
    public BackendUser getUserById(@PathVariable("id") Long usrId){


        return backendUserService.getById(usrId);
    }

}
